package com.banmao.rabbitmq.c1_workQueue;

import com.alibaba.fastjson2.JSON;
import com.banmao.rabbitmq.c1_workQueue.entity.SMS;
import com.banmao.rabbitmq.utils.RabbitConstant;
import com.banmao.rabbitmq.utils.RabbitUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class OrderSystem {

    public static void main(String[] args) throws Exception {

        Connection connection = RabbitUtil.getConnection();

        Channel channel = connection.createChannel();

        channel.queueDeclare(RabbitConstant.SMS,
                false, false, false, null);

        for (int i = 0; i < 30; i++) {
            SMS sms = new SMS("乘客" + i, "135" + i, "已预定");
            String msg = JSON.toJSONString(sms);
            channel.basicPublish("", RabbitConstant.SMS, null, msg.getBytes());
        }

        channel.close();
        connection.close();

    }

}
